import socket  

# 创建UDP socket
udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
#允许发广播
udp_socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, True)#o不允许发广播


message = "hello 你好！"
dest_addr = ("192.168.94.255", 8888)
udp_socket.sendto(message.encode("GBK"), dest_addr)
# 关闭socket
udp_socket.close()
